--- @param extension Package
--- @param HY HY_Utility
--- @param U Utility
return function(extension, HY, U)
    local hy_hakurei_reimu = General:new(extension, "hy_hakurei_reimu", "ten_k", 4, 4, General.Female)
    local magic_seal = fk.CreateSkill {
        name = "magic_seal",
    }
    magic_seal:addEffect("active", {
        anim_type = "control",
        can_use = function(self, player)
            return player:usedSkillTimes(magic_seal.name, Player.HistoryPhase) == 0
        end,
        card_num = 1,
        card_filter = function(self, player, to_select, selected)
            return #selected == 0 and table.contains(player:getCardIds("h"), to_select)
        end,
        target_num = 0,
        target_filter = Util.FalseFunc,
        prompt = function(self, selected, selected_cards)
            return "magic_seal_prompt"
        end,
        on_use = function(self, room, cardUseEvent)
            local card = Fk:getCardById(cardUseEvent.cards[1])
            local cardReal = Fk:getCardById(cardUseEvent.cards[1], true)
            local player = cardUseEvent.from
            player:addToPile("#magic_seal_card", card, true, magic_seal.name)
            player:drawCards(1, magic_seal.name)
            local marks = player:getMark("@magic_seal")
            if type(marks) ~= "table" then
                marks = {}
            end
            table.insertIfNeed(marks, cardReal:getSuitString(true))
            room:setPlayerMark(player, "@magic_seal", marks)
            if card.suit == Card.Heart then
                if not player.dead then
                    room:drawCards(player, 2, magic_seal.name)
                end
            elseif card.suit == Card.Club then
                local targets = {}
                for _, t in ipairs(room:getOtherPlayers(player)) do
                    if t.chained == false then
                        table.insert(targets, t)
                    end
                end
                if #targets == 0 then
                    return
                end
                local chain_targets = room:askToChoosePlayers(player, {
                    targets = targets,
                    min_num = 0,
                    max_num = 2,
                    prompt = "magic_seal_chained",
                    skill_name = magic_seal.name,
                })
                if #chain_targets == 0 then
                    return
                end
                for _, t in ipairs(chain_targets) do
                    t:setChainState(true)
                end
            elseif card.suit == Card.Spade then
                local targets = {}
                for _, t in ipairs(room:getOtherPlayers(player)) do
                    if player:inMyAttackRange(t) then
                        table.insert(targets, t)
                    end
                end
                if #targets == 0 then
                    return
                end
                local damage_targets = room:askToChoosePlayers(player, {
                    targets = targets,
                    min_num = 0,
                    max_num = 1,
                    prompt = "magic_seal_damage",
                    skill_name = magic_seal.name
                })
                if #damage_targets == 0 then
                    return
                end
                room:damage({
                    from = player,
                    to = damage_targets[1],
                    damage = 1,
                    damageType = fk.NormalDamage,
                    skillName = magic_seal.name
                })
            elseif card.suit == Card.Diamond then
                local targets = room:askToChooseToMoveCardInBoard(player, {
                    prompt = "magic_seal_obtain",
                    skill_name = magic_seal.name,
                })
                if #targets ~= 0 then
                    room:askToMoveCardInBoard(player, {
                        target_one = targets[1],
                        target_two = targets[2],
                        skill_name = magic_seal.name
                    })
                end
            end
        end
    })
    magic_seal:addEffect("prohibit", {
        prohibit_use = function(self, player, card)
            if card == nil then
                return false
            end
            if card.suit == Card.NoSuit then
                return false
            end
            if card:getEffectiveId() and not table.contains(player:getCardIds("h"), card:getEffectiveId()) and #card.subcards <= 1 then
                return false
            end
            local cardIds = {}
            for _, t in ipairs(Fk:currentRoom().alive_players) do
                if #t:getPile("#magic_seal_card") > 0 and t ~= player and t:hasSkill("magic_seal") then
                    table.insertTableIfNeed(cardIds, t:getPile("#magic_seal_card"))
                end
            end
            if #cardIds == 0 then
                return false
            end
            return table.any(cardIds, function(id)
                return Fk:getCardById(id).suit == card.suit
            end)
        end,
    })
    magic_seal:addEffect(fk.EventPhaseStart, {
        can_refresh = function(self, event, target, player)
            return target:hasSkill("magic_seal") and player == target and player.phase == Player.Start
        end,
        on_refresh = function(self, event, target, player)
            player.room:setPlayerMark(player, "@magic_seal", 0)
            if #player:getPile("#magic_seal_card") == 0 then
                return
            end
            player.room:moveCards({
                from = player,
                ids = player:getPile("#magic_seal_card"),
                toArea = Card.DiscardPile,
                moveReason = fk.ReasonPutIntoDiscardPile,
                skillName = magic_seal.name,
            })
        end
    })
    extension:loadSkillSkels { magic_seal }
    hy_hakurei_reimu:addSkill("magic_seal")
    Fk:loadTranslationTable {
        ["hy_hakurei_reimu"] = "博丽灵梦",
        ["#hy_hakurei_reimu"] = "人与妖的交界线",
        ["illustrator:hy_hakurei_reimu"] = "butyou",
        ["designer:hy_hakurei_reimu"] = "黑曜人形",
        ["cv:hy_hakurei_reimu"] = "",

        ["magic_seal"] = "封魔",
        [":magic_seal"] = "出牌阶段限一次，你可以将一张手牌置于你的武将牌上并摸一张牌，直到你的下个回合开始，其他角色无法使用与此牌花色相同的手牌，若此牌花色为：<br>&nbsp;&nbsp;&nbsp;&nbsp;♥，你摸两张牌；<br>&nbsp;&nbsp;&nbsp;&nbsp;♦，你可以移动场上一张牌；<br>&nbsp;&nbsp;&nbsp;&nbsp;♠，你可以对攻击范围内的一名角色造成1点伤害；<br>&nbsp;&nbsp;&nbsp;&nbsp;♣，你可以横置至多两名其他角色。<br>准备阶段，你移去所有“封魔”牌。",
        ["#magic_seal_card"] = "封魔",
        ["magic_seal_chained"] = "封魔：你可以横置至多两名其他角色",
        ["magic_seal_damage"] = "封魔：你可以对一名角色造成一点伤害",
        ["magic_seal_obtain"] = "封魔：你可以移动场上一张牌",
        ["@magic_seal"] = "封魔",
        ["magic_seal_prompt"] = "封魔：将一张手牌置于你的武将牌旁,根据此牌花色执行对应效果",
    }
end
